package com.qxglxt.qxgl.dao;

import com.qxglxt.qxgl.model.Users;

import javax.transaction.Transactional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

/**
 * IMemberDao
 */
public interface IUsersDao extends  JpaRepository<Users, Integer>,JpaSpecificationExecutor<Users>{

    @Transactional
    @Modifying
    @Query("update Users u set u.LoginName = :LoginName,u.ProtectEMail = :ProtectEMail,u.ProtectMTel = :ProtectMTel where u.Id= :Id")
    int editUsers(Integer Id,String LoginName,String ProtectEMail,String ProtectMTel);

    
    //用户登录
 
    @Query("select count(u.Id) from Users u where u.LoginName = :LoginName and u.Password=:Password")
    int login(String LoginName,String Password);

        //重置密码
        @Transactional
        @Modifying
        @Query("update Users u set u.Password='000000' where u.Id=:Id")
        int pwdReset(Integer Id);
        //锁定
        @Transactional
        @Modifying
        @Query("update Users u set u.IsLockout='是' where u.Id=:Id")
        int lockoutUser(Integer Id);
        //解锁
        @Transactional
        @Modifying
        @Query("update Users u set u.IsLockout='否' where u.Id=:Id")
        int notLockoutUser(Integer Id);
    

}